//
//  HelpCenterVC.m
//  MRBang
//
//  Created by 铅笔 on 16/5/13.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "HelpCenterVC.h"

@interface HelpCenterVC ()<UIWebViewDelegate>

@property (strong, nonatomic) UIWebView *browseWeb;

@end

@implementation HelpCenterVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"帮助中心";
    self.view.backgroundColor = COLOR_EVERYVIEWBG;
    
    //状态栏背景色
    UIView *statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20)];
    
    [self.view addSubview:statusBarView];
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
    
    self.browseWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0,64, kScreenWidth, kScreenHeight-64)];
    [self.view addSubview:self.browseWeb];
    
    NSURL *url=[NSURL URLWithString:@"http://www.mrbang.com.cn/helpinfo.php"];
    [self.browseWeb loadRequest:[NSURLRequest requestWithURL:url]];
    //此处是处理网页黑条条的状况
    self.browseWeb.opaque = NO;
    self.browseWeb.backgroundColor = [UIColor clearColor];
    [self.browseWeb setScalesPageToFit:NO];
    self.browseWeb.delegate = self;

}

#pragma mark 设置UIWebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];
    NSLog(@"url为%@",url);
    NSString*str =  [url absoluteString];
    if ([str rangeOfString:@"login"].location!=NSNotFound)
    {
        [self.browseWeb setScalesPageToFit:YES];
    }
    return YES;
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
